package cn.edu.scau.cmi.yangzhichao.multipleton;

import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TouchEvent;

import java.util.List;

public class BasketBallerViewController {
    @FXML
    private TextArea textArea;
    @FXML
    private TextField textField;
    @FXML
    private Button button;
    @FXML
    private PasswordField passwordField;
    @FXML
    private void initialize(){
    }
    @FXML
    private void handleOK(){
        if(textField.getText().toString().equals("")){
            Alert error = new Alert(Alert.AlertType.ERROR,"ERROR:输入为空");
            Button err = new Button();
            err.setOnAction((ActionEvent)->{

            });
            error.show();
        }else{
            List<BasketBaller>players=BasketBaller.getInstance(textField.getText().toString());
            System.out.println(players.size());
            textArea.setText(textArea.getText().toString()+players.get(players.size()-1).getName()+"已创建"+"\n");
        }
    }
    @FXML
    private void handleEnter(){
        EventHandler<KeyEvent> handler=new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent event) {
                if(event.getCode().equals(KeyCode.ENTER)){
                    handleOK();
                }
            }
        };
    }
}
